﻿/****
 * 
 * Code provenant de l'outils Bowis de codeplew
 * Merci !!!
 * 
 * *******/

using System;
using System.Windows.Forms;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Controls;

namespace WordTemplate1.Formulaire
{
    /// <summary>
    /// Permet la création d'un workitem
    /// </summary>
    public partial class CreateWorkitem : Form
    {
        #region Ctors

        private bool allowSave;

        /// <summary>
        /// Ctor
        /// </summary>
        public CreateWorkitem()
        {
            InitializeComponent();
        }
        

        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="store">Work Item Store</param>
        /// <param name="workItem">Work Item to display</param>
        public CreateWorkitem(WorkItem workItem, bool allowSave)
            : this()
        {
            this.m_workItem = workItem;
            this.allowSave = allowSave;
        }

        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="store">Work Item Store</param>
        /// <param name="workItem">Work Item to display</param>
        public CreateWorkitem(WorkItemStore store, WorkItem workItem)
            : this()
        {
            this.m_workItem = workItem;
        }

        #endregion

        #region Fields

        private WorkItem m_workItem;

        #endregion

        /// <summary>
        /// Form Load Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateWorkitem_Load(object sender, EventArgs e)
        {
            WorkItemFormControl frm = new WorkItemFormControl();

            frm.FormDefinition = m_workItem.DisplayForm;
            frm.Item = m_workItem;
            frm.ReadOnly = false;

            this.pnlInformation.Controls.Add(frm);
            frm.Dock = DockStyle.Fill;

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            m_workItem.Save();
            Globals.ThisDocument.taskPanel.Actualise();
            this.Close();
        }

        private void btnAnnuler_Click(object sender, EventArgs e)
        {
            this.Close();
        }


    }
}
